﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nb.Common;
using Nb.Common.SystemDates;

namespace Nb.Tools.MachineCodeTracker
{
    class Program
    {
        static void Main(string[] args)
        {
            var sysDateRegistry = SystemDateServiceRegistry.Instance;
            var systemDateService = sysDateRegistry.GetService();
            Console.WriteLine(systemDateService.Now());
            
            var sysDateRegistry2 = SystemDateServiceRegistry.Instance;
            Console.WriteLine(sysDateRegistry.GetHashCode());
            Console.WriteLine(sysDateRegistry2.GetHashCode());
            Console.Read();

            ////0FABFBFF000306A9
            ////BFEBFBFF000306A9
            //SystemDateManager.AddProviderFunc(() => new DefaultSystemDateProvider());

            //var readMachineInfo = MachineInfoReader.ReadMachineInfo(false);
            //var s = readMachineInfo.ToString();
            //Console.WriteLine(s);
            //MyIOHelper.SaveFile("c:\\info.txt", s, Encoding.UTF8);

            //var machineCodeService = new MachineCodeService();
            //var makeMachineCode = machineCodeService.MakeMachineCode(readMachineInfo);
            //Console.WriteLine(makeMachineCode);
            //Console.Read();
            return;

            //CheckStaticInGenericClass();
            //CheckStaticCountInGenericClass();

            //MachineCodeWatcher.Start();

            //Console.ReadLine();

            //MachineCodeWatcher.Stop();
        }

        private static void CheckStaticInGenericClass()
        {
            Console.WriteLine(MyClass<string>._lock == SubClass2._lock);
            Console.WriteLine(SubClass._lock == SubClass2._lock);
            Console.WriteLine(MyClass<int>._lock == MyClass<string>._lock);
            Console.WriteLine("------------");
            //Console.WriteLine(MyClass<string>._lock == MyClass<string>._lock);
            //Console.WriteLine(MyClass<int>._lock == SubClass2._lock);

            Console.ReadLine();
        }
        private static void CheckStaticCountInGenericClass()
        {
            Console.WriteLine(++MyClass<string>.Count);
            Console.WriteLine(++MyClass<int>.Count);
            Console.WriteLine(++SubClass.Count);
            Console.WriteLine(++SubClass2.Count);

            Console.ReadLine();
        }
    }

    public abstract class MyClass<T>
    {
        public static  int Count { get; set; }
        public static object _lock = new object();
    }

    public class SubClass : MyClass<String>
    {

    }
    public class SubClass2 : MyClass<int>
    {

    }
}
